home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
addpcx.zip
/
PCXDISP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-06-21
|
3KB
|
114 lines
/* PCXDISP.c - Load pictures into RAM and display them
*/
#include "lib.h"
#include "pcx.h"
extern int pcx_md;
void pcx_load_palette( pic )
PCXPIC *pic;
{
int p;
if ( pcx_md )
{ /* this part NOT TESTED */
VGR_CPAL( pic->hdr.triple[0].red / 16, pic->hdr.triple[1].red / 32 );
return;
};
for ( p=0; p < 16; p++ )
VGR_PALETTE( p, pic->hdr.triple[p].red / 85,
pic->hdr.triple[p].green / 85,
pic->hdr.triple[p].blue / 85 );
}
void pcx_showpic( pic, hoffs, voffs, load_palette_flg )
int load_palette_flg, hoffs, voffs;
PCXPIC *pic;
{
int plane, row, nrows, nplan, nbytes;
nrows = pic->hdr.y2 - pic->hdr.y1 +1;
nplan = pic->hdr.nplanes;
nbytes= pic->hdr.bpl;
nrows = nrows > VGR_VRES ? VGR_VRES : nrows;
nbytes = nbytes > VGR_NBPL ? VGR_NBPL : nbytes;
for ( plane = 0; plane < nplan; plane++ )
{ VGR_PLANE(plane ? plane : -0x0f);
for ( row = 0; row < nrows; row++ )
VGR_ROW( row, pic->rows[plane][row+voffs] + hoffs, nbytes );
};
if ( load_palette_flg )
pcx_load_palette( pic );
}
#ifdef PCX_DUMP_PIC
void pcx_dump_pic( pic )
PCXPIC *pic;
{
#define err_printf printf
#define XX(x,fmt) err_printf( #x "=" fmt, hdr->x )
int i, j;
PCXHDR *hdr;
hdr = &pic->hdr;
err_printf("Hex Dump of entire header:\n");
dumpbuf( (uchar *)hdr, sizeof(*hdr) );
err_printf("hit ESC to quit dump, ENTER for more:");
while ( (i = conin()) != 27 && i != 13 )
errbeep();
err_printf("\n");
if ( i == 27 )
return;
XX(maker,"%u ");
XX(version,"%u ");
XX(code,"%u ");
XX(bpp,"%u\n");
XX(x1,"%u ");
XX(y1,"%u ");
XX(x2,"%u ");
XX(y2,"%u\n");
XX(hres,"%u ");
XX(vres,"%u ");
XX(vmode,"%u ");
XX(nplanes,"%u ");
XX(bpl,"%u\n");
for ( i=0; i < 16; i++ )
err_printf("%2d: R%02x G%02x B%02x ",
i, hdr->triple[i].red, hdr->triple[i].green, hdr->triple[i].blue );
err_printf("\nHit ESC to quit dump, ENTER for more:");
while ( (i = conin()) != 27 && i != 13 )
errbeep();
err_printf("\n");
if ( i == 27 )
return;
err_printf("Dumping ROWs, hit ESC to quit dump\n");
for ( i=0; i < hdr->nplanes; i++ )
for ( j=0; j < (hdr->y2 - hdr->y1 +1); j++ )
{ if ( pic->rows[i][j] )
{ err_printf("Plane %d, Row %d\n", i, j );
dumpbuf( (UC *)pic->rows[i][j], hdr->bpl );
if ( constat() && conin() == 27 )
return;
};
};
err_printf("hit any key to continue\n");
conin();
}
#endif